package cool.mtc.base.plugin.generator.code.model.template.bg;

import cool.mtc.core.util.StringUtil;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * @author 明河
 * <p>
 * Controller层模参数
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class BgControllerTemplateParam extends BaseBgTemplateParam {

    /**
     * Controller层生成Swagger UI文档的tag
     */
    private String tag;

    /**
     * Controller Url相对路径
     */
    private String url;

    @Override
    public String getTemplateRelativePath() {
        return "bg/controller.ftl";
    }

    @Override
    public String getBasePackage() {
        return this.getControllerBasePackage();
    }

    @Override
    public String getClassName() {
        return this.getClassPrefix() + "Controller";
    }

    @Override
    public void handleCheckParamsCorrect() {
        super.handleCheckParamsCorrect();
        if (StringUtil.isEmpty(this.getUrl())) {
            throw new RuntimeException(this.handleMessage("未设置[url]"));
        }
        if (StringUtil.isEmpty(this.getTag())) {
            throw new RuntimeException(this.handleMessage("未设置[tag]"));
        }
    }
}
